<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片切换</title>
</head>

<body>
    <div id="mask">
        <div class="center">
            <h2 class="title">
                <img src="./img/logo.png" alt="">
                小猫图片
            </h2>
            <!-- 图片 -->
            <img :src="imgArr[index]" alt="">
            <!-- 左箭头 -->
            <a href="javascript:void(0)" v-show="index!=0" @click="prev" class="left">
                <img src="./img/prev.png" alt="">
            </a>
            <!-- 右箭头 -->
            <a href="javascript:void(0)" v-show="index<imgArr.length-1" @click="next" class="right">
                <img src="./img/next.png" alt="">
            </a>
        </div>
    </div>

    <!-- 开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var app = new Vue({
            el: "#mask",
            data: {
                imgArr: [
                    "./img/xiaomao-003.jpg",
                    "./img/xiaomao-004.jpg",
                    "./img/xiaomao-005.jpg",
                    "./img/xiaomao-008.jpg",
                    "./img/xiaomao-009.jpg",
                    "./img/xiaomao-014.jpg"
                ],
                index: 0
            },
            methods: {
                prev: function () {
                    this.prev++;
                },
                next: function () {
                    this.next--;
                }
            }
        })
    </script>
</body>

</html>